package vip.youngboy.freejump.handler.event;

import org.activiti.engine.delegate.event.ActivitiEntityEvent;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import vip.youngboy.freejump.repository.TaskOpinionRepository;

public class TaskAssigneeEventHandler extends AbstractTaskEventHandler {

    protected TaskOpinionRepository taskOpinionRepository;

    @Override
    public void handleTaskEvent(ActivitiEntityEvent event) {
        //持久化流程执行堆栈记录和历史审批记录
        TaskEntity entity = (TaskEntity) event.getEntity();
        recordTaskOpinion(entity);
    }

    /**
     * 任务被委派人员时触发
     */
    protected void recordTaskOpinion(TaskEntity entity) {
        //TODO 这里一般发发短信通知代办人

    }

    @Override
    public ActivitiEventType supportType() {
        return ActivitiEventType.TASK_ASSIGNED;
    }
}
